package com.bsoft.hospitalchs.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by 泅渡者
 * Created on 2017/4/27.
 */

public class Utils {
    public static int getVersion(Context context) {
        int versioncode = 0;
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(),
                    0);
            String version = info.versionName;
            versioncode = info.versionCode;
            return versioncode;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return versioncode;
    }
    public static int getDrawableFromName(Context context,String sourceName){

        return context.getResources().getIdentifier(sourceName, "mipmap" , context.getPackageName());
    }
}
